import { observable,action,configure } from 'mobx';
import 'whatwg-fetch'
import agent from '../libs/agent'
configure({ enforceActions: "observed" })
class UserStore {
    @observable user ={};
    @observable username = "";
    @observable password = "";
    @observable email = "";
    @action
    getUser() {
        return this.user;
    }

    @action
    setUser(){
          return agent.Auth.login().then((data)=>{
              return data;
          }).catch((e)=>{
              throw e;
        })
    }

    @action
    setEmail(email){
        this.email = email;
    }

    @action
    setUsername(username){
        this.username = username;
    }

    @action
    setPassword(password){
        this.password = password;
    }

    @action reset() {
        this.username = '';
        this.email = '';
        this.password = '';
    }
}
export default new UserStore();